home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-30 | 20.6 KB | 580 lines | [TEXT/MPS ] |
- //
- // fileCompress.r - an example of how to use InstaCompOne compression
- //
- //
- // How To Build the Script:
- //
- // To build Installer script access "Build…" item within "Build" menu
- // and enter the scriptName "fileCompress". To build the Installer
- // debugger version of the Installer script enter the scriptname
- // with the addition ".debug" ( "fileCompress.debug" ).
- //
- // There must be a copy of the file "InstaCompOneSCExt.rsrc"
- // that has been renamed to "fileCompress.scx" included in this
- // folder as well. This file will automatically be copied and
- // renamed ( from the InstaCompOne folder in the SDK ) when the
- // makefile for this example is run.
- //
- // What this example does :
- //
- // This Installer script source demonstrates use of InstaCompOne
- // archives, split files, the InstaCompOneTool compression utility,
- // and the FileAndRsrcSplitterTool for use in installing files.
- //
- // All target files from example installations are placed in a folder
- // called ":InstaComp Testing:" on the root folder of the target volume
- // of installation. Performing a "GetInfo" on the resulting file(s) will
- // display information identifying from which method the file was installed.
- // The three methods are: file compression, file splitting, file compression
- // and splitting.
- //
- // IMPORTANT: You must use the flag "rsrcForkInDataFork" in file atoms when using
- // InstaCompOne to compress files. This enables the Installer to find the compressed
- // resource fork in the data fork of the archive file.
- //
- // NOTE: InstaCompOne can be used to split and compress resources and fonts
- // in addition to files, but this example deals only with splitting and
- // compressing files. The major difference between working with files and
- // working with resources ( and fonts ) is that compressed items will usually
- // be stored in the data fork of an archive when working with files and will
- // be stored in the resource fork of an archive when working with resources
- // and fonts.
- //
- //
- // The following MPW commands for compression and splitting are already
- // contained in the makefile for this example. They have been included
- // here for your convenience. Running the makefile will demonstrate all
- // the commands listed below.
- //
- // • simple file compression example ( no splitting )
- //
- // - To compress "Example File • 1" into an archive called "Tome" within "Disk 1:"
- // InstaCompOneTool "Example File • 1" -o ":Disk 1:Tome"
- //
- //
- // • split and compressed file example
- //
- // - To split our file into two resource forks :
- // FileAndRsrcSplitterTool "Example File • 2" -s 1650 -o "splitCompReadMe"
- // - The above line specifies that the maximum size for any split piece be 1650 bytes.
- // Such a small size was specified since our example file is so small.
- // Normally, you will want the maximum size to be much larger.
- // - This split will result in three files within the current folder
- // named "splitCompReadMe.rsrc1", "splitCompReadMe.rsrc2", "splitCompReadMe.data1"
- // - IMPORTANT: The FileAndRsrcSplitterTool will create a separate file for the orginal
- // file's data fork. If your original file has a data fork, you will also need to
- // create two 'infa's, one to copy the resource fork and anothe to copy the data fork.
- //
- // - To compress the first split piece into an archive in ":Disk 1:"
- // InstaCompOneTool "splitCompReadMe.rsrc1" -o ":Disk 1:splitCompTome1" -f "Example File • 2" -e
- //
- // - To compress the second split piece into an archive in ":Disk 2:"
- // InstaCompOneTool "splitCompReadMe.rsrc2" -o ":Disk 2:splitCompTome2" -f "Example File • 2" -e
-
- // - To compress the data fork split piece into an archive in ":Disk 2:"
- // InstaCompOneTool "splitCompReadMe.rsrc2" -o ":Disk 2:splitCompTome3" -f "Example File • 2"
- // - IMPORTANT: Notice that we do not specify the "-e" option when compressing the data fork.
- //
- // • simple split file example ( no compression )
- //
- // - To split a file into two resource forks (and one data fork):
- // FileAndRsrcSplitterTool "Example File • 3" -s 1650 -o "splitReadMe"
- // - this will result in three files within the current folder
- // - named "splitReadMe.rsrc1", "splitReadMe.rsrc2", and "splitReadMe.data1"
- //
- // - To place both these pieces in the installation disk folders :
- // Duplicate "splitReadMe.rsrc1" -y ":Disk 1:splitTome1"
- // Duplicate "splitReadMe.rsrc2" -y ":Disk 2:splitTome2"
- // Duplicate "splitReadMe.data1" -y ":Disk 2:splitTome3"
- //
- //
- //
- //
- // NOTE: Always use the target filename ( contained in the target file
- // spec 'intf' ) when compressing a file into an archive. This will
- // ensure that the InstaCompOne decompression utility can successfully
- // locate and decompress the contents of the archive during installation.
- // A full target path for the destination file should be entered in the
- // 'intf' resource, but only the actual filename will be used when extracting
- // compressed file items from within an archive.
- //
- // NOTE: When using InstaCompOne compression and splitting, simply enter 241
- // as the value for the atom extender ( 'inex' ) in the next to last field
- // of the atom ( 'infa', 'inff', 'inra' ) for the file/font/rsrc to be
- // decompressed. There is no need to declare an 'inex' resource within the
- // Installer script source. An 'inex' resource definition is contained in
- // the InstaCompOne resource file that is included at the top of this file.
- //
- //
- //
- // Copyright 1993-1996, Apple Computer, Inc., All Rights Reserved
- //
-
- #include "InstallerTypes.r"
-
- // Include the InstaCompOne atom extender stuff
- // making sure not to add their version resource
- // to our installer script. Also, since this include
- // is a resource include instead of a #include, it is
- // not actually a pre-processor thing, and won't be effected
- // by a -i option within the rez line in the makefile.
- include ":::Tools:Released:InstaCompOne 1.1:InstaCompAtomExt.rsrc" NOT 'vers';
-
-
- // • packages
-
- // package that demonstrates simple case of archive,
- // one file in archive decompressed to target volume
- resource 'inpk' (100) {
- format0 {
- showsOnCustom,
- removable,
- dontForceRestart,
- 0,
- 0,
- "Example File - using InstaCompOne compression.",
- {
- 'infa', 1000;
- },
- }
- };
-
- // package that demonstrates decompressing two archives and
- // joining the results into one target file
- resource 'inpk' (200) {
- format0 {
- showsOnCustom,
- removable,
- dontForceRestart,
- 0,
- 0,
- "Example File - using file splitting and InstaCompOne compression.",
- {
- 'infa', 2000; // resource fork
- 'infa', 2002; // data fork
- },
- }
- };
-
- // package that demonstrates decompressing two archives and
- // joining the results into one target file
- resource 'inpk' (300) {
- format0 {
- showsOnCustom,
- removable,
- dontForceRestart,
- 0,
- 0,
- "Example File - using file splitting, but no compression.",
- {
- 'infa', 3000; // resource fork
- 'infa', 3003; // data fork
- },
- }
- };
-
-
- // • file atoms
-
- // • simple compression example
- // single source file => single archive => single target file
- resource 'infa' (1000) {
- format1 {
- deleteWhenRemoving, // Delete on deinstall
- deleteWhenInstalling, // Remove preexisting
- copy, // Copy on Install
- dontIgnoreLockedFile, // Respect file locking
- dontSetFileLocked, // Leave installed file unlocked
- useSrcCrDateToCompare, // Use creation date for compare
- srcNeedNotExist, // Create a new file if necessary
-
- // this line must be set to "rsrcForkInDataFork" when working
- // file items compressed into InstaCompOne archives
- rsrcForkInDataFork, // • Resource fork in Data fork
-
- leaveAloneIfNewer, // Do not update a newer file
- updateExisting, // Update an existing file
- copyIfNewOrUpdate, // Copy whether target exists or not
- rsrcFork, // Copy resource fork
- dataFork, // Copy data fork
-
- 0, // TARGET - size ( filled in by ScriptCheck )
- 0x0, // finder attribute flags ( filled in by ScriptCheck )
- 10000, // TARGET - file spec ( 'intf' )
- {
- 10001, // SOURCE - file spec ( 'infs' )
- 0, // DATA fork - size ( filled in by ScriptCheck )
- 0 // RSRC fork - size ( filled in by ScriptCheck )
- },
-
- 0x0, // SOURCE - version number for comparisons
- // not used here
-
- 0, // 'invc' code resource - version comparison routine
- // ( none used here )
-
- 241, // 'inex' resource definition for atom extender
- // • #241 is for InstaCompOne extender
-
- "Example File • 1" // file atom description
- }
- };
-
-
- // • split file compression example
- // • file atom for resource fork
- // single source file => split resource fork => 2 resource archives => single target file
- resource 'infa' (2000) {
- format1 {
- deleteWhenRemoving, // Delete on deinstall
- deleteWhenInstalling, // Remove preexisting
- copy, // Copy on Install
- dontIgnoreLockedFile, // Respect file locking
- dontSetFileLocked, // Leave installed file unlocked
- useSrcCrDateToCompare, // Use creation date for compare
- srcNeedExist, // Require a source file
-
- // this line must be set to "rsrcForkInDataFork" when working
- // file items compressed into InstaCompOne archives
- rsrcForkInDataFork, // • Resource fork in Data fork
-
- leaveAloneIfNewer, // Do not update a newer file
- updateExisting, // Update an existing file
- copyIfNewOrUpdate, // Copy whether target exists or not
- rsrcFork, // Copy resource fork
- dataFork, // Copy data fork
-
- 0, // TARGET - size ( filled in by ScriptCheck )
- 0x0, // finder attribute flags ( filled in by ScriptCheck )
- 20000, // TARGET - file spec ( 'intf' )
- {
- // • IMPORTANT - the split and compressed pieces must be listed
- // • in the same order here as when they were split. In other
- // • words the piece that was split off first ( and was given
- // • the ".rsrc1" ending ) should be listed first in the lines below.
- // • then comes the piece with the ".rsrc2" ending, etc.
-
- 20001, // SOURCE - file spec ( 'infs' )
- 0, // DATA fork - size ( filled in by ScriptCheck )
- 0, // RSRC fork - size ( filled in by ScriptCheck )
-
- 20002, // SOURCE - file spec ( 'infs' )
- 0, // DATA fork - size ( filled in by ScriptCheck )
- 0, // RSRC fork - size ( filled in by ScriptCheck )
- },
-
- 0x0, // SOURCE - version number for comparisons,
- // not used here
-
- 0, // 'invc' code resource - version comparison routine
- // ( none used here )
-
-
- 241, // 'inex' resource definition for atom extender
- // • #241 is for InstaCompOne extender
-
- "Example File • 2" // file atom description
- }
- };
-
- // • file atom for data fork
- // single source file => split data fork => data fork archive => single target file
- resource 'infa' (2002) {
- format1 {
- deleteWhenRemoving, // Delete on deinstall
- deleteWhenInstalling, // Remove preexisting
- copy, // Copy on Install
- dontIgnoreLockedFile, // Respect file locking
- dontSetFileLocked, // Leave installed file unlocked
- useSrcCrDateToCompare, // Use creation date for compare
- srcNeedExist, // Require a source file
-
- // this line must be set to "rsrcForkInDataFork" when working
- // file items compressed into InstaCompOne archives
- rsrcForkInDataFork, // • Resource fork in Data fork
-
- leaveAloneIfNewer, // Do not update a newer file
- updateExisting, // Update an existing file
- copyIfNewOrUpdate, // Copy whether target exists or not
- noRsrcFork, // Copy resource fork
- dataFork, // Copy data fork
-
- 0, // TARGET - size ( filled in by ScriptCheck )
- 0x0, // finder attribute flags ( filled in by ScriptCheck )
- 20000, // TARGET - file spec ( 'intf' )
- {
- 20003, // SOURCE - file spec ( 'infs' )
- 0, // DATA fork - size ( filled in by ScriptCheck )
- 0 // RSRC fork - size ( filled in by ScriptCheck )
- },
-
- 0x0, // SOURCE - version number for comparisons,
- // not used here
-
- 0, // 'invc' code resource - version comparison routine
- // ( none used here )
-
-
- 0, // we did not compress, so there is no atom extender
-
- "Example File • 2" // file atom description
- }
- };
-
-
-
- // • split file w/o compression example
- // single source file => split resource fork => single target file
- resource 'infa' (3000) {
- format1 {
- deleteWhenRemoving, // Delete on deinstall
- deleteWhenInstalling, // Remove preexisting
- copy, // Copy on Install
- dontIgnoreLockedFile, // Respect file locking
- dontSetFileLocked, // Leave installed file unlocked
- useSrcCrDateToCompare, // Use creation date for compare
- srcNeedExist, // Require a source file
-
- // this line must be set to "rsrcForkInDataFork" when working
- // file items compressed into InstaCompOne archives
- rsrcForkInDataFork, // • Resource fork in Data fork
-
- leaveAloneIfNewer, // Do not update a newer file
- updateExisting, // Update an existing file
- copyIfNewOrUpdate, // Copy whether target exists or not
- rsrcFork, // Copy resource fork
-
- noDataFork, // • Don't Copy data fork
- // 'noDataFork' must be set
- // when splitting the resource
- // fork but not compressing the pieces
-
- 0, // TARGET - size ( filled in by ScriptCheck )
- 0x0, // finder attribute flags ( filled in by ScriptCheck )
- 30000, // TARGET - file spec ( 'infs' )
- {
- // • IMPORTANT - the split pieces must be listed in the
- // • same order here as when they were split. In other
- // • words the piece that was split off first ( and was given
- // • the ".rsrc1" ending ) should be listed first in the lines below.
- // • then comes the piece with the ".rsrc2" ending, etc.
-
- 30001, // SOURCE - file spec ( 'infs' )
- 0, // DATA fork - size ( filled in by ScriptCheck )
- 0, // RSRC fork - size ( filled in by ScriptCheck )
-
- 30002, // SOURCE - file spec ( 'infs' )
- 0, // DATA fork - size ( filled in by ScriptCheck )
- 0, // RSRC fork - size ( filled in by ScriptCheck )
- },
-
- 0x0, // SOURCE - version number for comparisons
- // not used here
-
- 0, // 'invc' code resource - version comparison routine
- // ( none used here )
-
-
- 0, // 'inex' resource definition for atom extender
- // don't use atom extender for simple split files
-
- "Example File • 3" // file atom description
- }
- };
-
- // • split file w/o compression example
- // single source file => split data fork => single target file
- resource 'infa' (3003) {
- format1 {
- deleteWhenRemoving, // Delete on deinstall
- deleteWhenInstalling, // Remove preexisting
- copy, // Copy on Install
- dontIgnoreLockedFile, // Respect file locking
- dontSetFileLocked, // Leave installed file unlocked
- useSrcCrDateToCompare, // Use creation date for compare
- srcNeedExist, // Require a source file
-
- // this line must be set to "rsrcForkInDataFork" when working
- // file items compressed into InstaCompOne archives
- rsrcForkInDataFork, // • Resource fork in Data fork
-
- leaveAloneIfNewer, // Do not update a newer file
- updateExisting, // Update an existing file
- copyIfNewOrUpdate, // Copy whether target exists or not
- noRsrcFork, // • Don't Copy resource fork
-
- dataFork, // • Copy data fork
-
- 0, // TARGET - size ( filled in by ScriptCheck )
- 0x0, // finder attribute flags ( filled in by ScriptCheck )
- 30000, // TARGET - file spec ( 'infs' )
- {
-
- 30003, // SOURCE - file spec ( 'infs' )
- 0, // DATA fork - size ( filled in by ScriptCheck )
- 0 // RSRC fork - size ( filled in by ScriptCheck )
- },
-
- 0x0, // SOURCE - version number for comparisons
- // not used here
-
- 0, // 'invc' code resource - version comparison routine
- // ( none used here )
-
-
- 0, // 'inex' resource definition for atom extender
- // don't use atom extender for simple split files
-
- "Example File • 3" // file atom description
- }
- };
-
-
- // • compressed - file specs
-
- // • simple compression
- // target file spec for decompressed "Example File" file
- resource 'intf' (10000) {
- format1 {
- noSearchForFile, // use default search path
- TypeCrNeedNotMatch, // target type and creator don't have to match
- 'ttro', // TYPE given to new file
- 'ttxt', // CREATOR given to new file
-
- 0x0, // Target - finder flags
- // ( ScriptCheck fills in flags if set to 0 )
-
- 0x1, // Target - creation date
- 0x1, // Target - mod date
- // ( ScriptCheck fills in dates if set to 1 )
-
- 0, // 'insp' resource ID ( file search proc )
- ":File Compression/Split Example:Example File • 1" // path to target file
- }
- };
-
-
- // • simple compression
- // source file spec for compressed "Example File" file
- resource 'infs' (10001) {
- 'idcp', // TYPE
- 'kakc', // CREATOR
- 0x0, // creation DATE for source file
- noSearchForFile, // IGNORED in Installer 4.0.x
- TypeCrMustMatch, // TYPE, CREATOR must match file on install disk
- "Disk 1:Tome" // PATH to source file
- };
-
- // • split and compressed - file specs
-
- // • split resource fork with compression
- // shared target file spec to result from joining split pieces in archives
- resource 'intf' (20000) {
- format1 {
- noSearchForFile, // use default search path
- TypeCrNeedNotMatch, // target type and creator don't have to match
- 'ttro', // TYPE given to new file
- 'ttxt', // CREATOR given to new file
-
- 0x0, // Target - finder flags
- // ( ScriptCheck fills in flags if set to 0 )
-
- 0x1, // Target - creation date
- 0x1, // Target - mod date
- // ( ScriptCheck fills in dates if set to 1 )
-
- 0, // 'insp' resource ID ( file search proc )
- ":File Compression/Split Example:Example File • 2" // path to target file
- }
- };
-
- // • split resource fork with compression
- // source file spec for archive containing one piece of split file
- resource 'infs' (20001) {
- 'idcp', // TYPE
- 'kakc', // CREATOR
- 0x0, // creation DATE for source file
- noSearchForFile, // IGNORED in Installer 4.0.x
- TypeCrMustMatch, // TYPE, CREATOR must match file on install disk
- "Disk 1:splitCompTome1" // PATH to source file
- };
-
- // • split resource fork with compression
- // source file spec for archive containing one piece of split file
- resource 'infs' (20002) {
- 'idcp', // TYPE
- 'kakc', // CREATOR
- 0x0, // creation DATE for source file
- noSearchForFile, // IGNORED in Installer 4.0.x
- TypeCrMustMatch, // TYPE, CREATOR must match file on install disk
- "Disk 2:splitCompTome2" // PATH to source file
- };
-
- // • split data fork with compression
- // source file spec for archive containing one piece of split file
- resource 'infs' (20003) {
- 'splt', // TYPE
- 'heyu', // CREATOR
- 0x0, // creation DATE for source file
- noSearchForFile, // IGNORED in Installer 4.0.x
- TypeCrMustMatch, // TYPE, CREATOR must match file on install disk
- "Disk 2:splitCompTome3" // PATH to source file
- };
-
- // • split - file specs
-
- // • split resource fork with compression
- // shared target file spec to result from joining split pieces in archives
- resource 'intf' (30000) {
- format1 {
- noSearchForFile, // use default search path
- TypeCrNeedNotMatch, // target type and creator don't have to match
- 'ttro', // TYPE given to new file
- 'ttxt', // CREATOR given to new file
-
- 0x0, // Target - finder flags
- // ( ScriptCheck fills in flags if set to 0 )
-
- 0x1, // Target - creation date
- 0x1, // Target - mod date
- // ( ScriptCheck fills in dates if set to 1 )
-
- 0, // 'insp' resource ID ( file search proc )
- ":File Compression/Split Example:Example File • 3" // path to target file
- }
- };
-
- // • split resource fork
- // source file spec for archive containing one piece of split file
- resource 'infs' (30001) {
- 'splt', // TYPE
- 'heyu', // CREATOR
- 0x0, // creation DATE for source file
- noSearchForFile, // IGNORED in Installer 4.0.x
- TypeCrMustMatch, // TYPE, CREATOR must match file on install disk
- "Disk 1:splitTome1" // PATH to source file
- };
-
- // • split resource fork
- // source file spec for archive containing one piece of split file
- resource 'infs' (30002) {
- 'splt', // TYPE
- 'heyu', // CREATOR
- 0x0, // creation DATE for source file
- noSearchForFile, // IGNORED in Installer 4.0.x
- TypeCrMustMatch, // TYPE, CREATOR must match file on install disk
- "Disk 2:splitTome2" // PATH to source file
- };
-
- // • split data fork
- // source file spec for archive containing one piece of split file
- resource 'infs' (30003) {
- 'splt', // TYPE
- 'heyu', // CREATOR
- 0x0, // creation DATE for source file
- noSearchForFile, // IGNORED in Installer 4.0.x
- TypeCrMustMatch, // TYPE, CREATOR must match file on install disk
- "Disk 2:splitTome3" // PATH to source file
- };
-
-